<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .fixed {
            height: 300px;
            background-color: lightskyblue;
            line-height: 300px;
            text-align: center;
            position: fixed;
            width: 100%;
        }

        .scroll {
            height: 1000px;
            background-color: lightgrey;
            /* padding-top: 300px; */
            z-index: 2;
            position: absolute;
            top: 300px;
            /* left: 0; */
            width: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        #top {
            position: absolute;
            top: 0px;

        }

        #bottom {
            position: absolute;
            bottom: 0;
            line-height: 20px;
            left: 47%;
        }
    </style>
</head>
<body>
<div class="fixed">
    我是固定的
    <p id="bottom">我是底部</p>
</div>
<div class="scroll">
    <p id="top">我是顶部</p>
    <p> 我是滑动的</p>
    <button id="button1" onclick=click1()>true或无</button>
    <button id="button2" onclick=click2()>false</button>
    <button id="button3" onclick=click3()>其他参数</button>
</div>
<script>
    /*
        详情:参见P456
     */
    function click1() {
        let button = document.querySelector('#button1')
        button.scrollIntoView(true);
    }

    function click2() {
        let button = document.querySelector('#button2')
        button.scrollIntoView(false);
    }

    function click3() {
        let button = document.querySelector('#button3')
        button.scrollIntoView({block: 'start'});
    }
</script>
</body>
</html>